package com.lhf.series.test.custmoerviewexample;

import android.app.Activity;
import android.os.Bundle;

import com.lhf.series.test.custmoerviewexample.adapter.MyAdapter;
import com.lhf.series.test.custmoerviewexample.view.MyListView;

import java.util.ArrayList;
import java.util.List;

/**
 * 自定义view
 * Created by lihf on 16/9/18.
 */
public class CustomerViewActivity extends Activity {

    private MyListView myListView;
    private MyAdapter adapter;
    private List<String> contentList = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.simple_view_layout);
//        setContentView(R.layout.my_view_layout);
//        setContentView(R.layout.counter_view_layout); //自绘控件
//        setContentView(R.layout.title_view_rl); //自绘控件
        setContentView(R.layout.extend_view_layout); //继承控件

        initList();

        myListView = (MyListView) findViewById(R.id.my_list_view);
        myListView.setOnDeleteListener(new MyListView.OnDeleteListener() {
            @Override
            public void onDelete(int index) {
                contentList.remove(index);
                adapter.notifyDataSetChanged();
            }
        });

        adapter = new MyAdapter(this,0,contentList);
        myListView.setAdapter(adapter);
    }

    public void initList(){
        contentList.add("Content item 1");
        contentList.add("Content item 2");
        contentList.add("Content item 3");
        contentList.add("Content item 4");
        contentList.add("Content item 5");
        contentList.add("Content item 6");
        contentList.add("Content item 7");
        contentList.add("Content item 8");
        contentList.add("Content item 9");
        contentList.add("Content item 10");
        contentList.add("Content item 11");
        contentList.add("Content item 12");
        contentList.add("Content item 13");
        contentList.add("Content item 14");
        contentList.add("Content item 15");
    }





}
